package com.sixney.app.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentTransaction;
import android.view.MenuItem;
import android.widget.ImageView;

import com.sixney.app.R;
import com.sixney.app.fragment.MovieFragment;
import com.sixney.app.fragment.MovieTheatersFragment;
import com.sixney.app.fragment.core.BetterFragment;


public class MovieTheatersActivity extends FragmentActivity {

    BetterFragment fragment;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        //getWindow().requestFeature(Window.FEATURE_ACTION_BAR_OVERLAY);
        setContentView(R.layout.activity_movie_theaters);
        getActionBar().setIcon(R.drawable.ic_in_app);

        ImageView view = (ImageView) findViewById(android.R.id.home);
        view.setPadding(10, 0, 0, 0);

        charger();
        remplir();
        ajouterListener();


    }

    public void ajouterFragment(BetterFragment fragment) {

    }

    private void charger() {
        getActionBar().setHomeButtonEnabled(true);
        getActionBar().setDisplayHomeAsUpEnabled(true);
    }

    private void remplir() {

        Intent intent = getIntent();
        String jsonMovie = intent.getStringExtra(MovieFragment.MOVIE);
        fragment = MovieTheatersFragment.newInstance(jsonMovie);


        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.replace(R.id.fragmentLayout, fragment);
        ft.commit();

    }

    private void ajouterListener() {
    }

    @Override
    public boolean onMenuItemSelected(int featureId, MenuItem item) {
        switch (item.getItemId()) {
            case android.R.id.home:
                super.onBackPressed();
                return true;
        }
        ;
        return super.onMenuItemSelected(featureId, item);
    }
}
